<?php

use Biz\service\miniProgram\GoodsRecommend as sGoodsRecommend;
use Biz\service\miniProgram\HotSales as sHotSales;
use Biz\model\activity\MiniTab as mMiniTab;
use Biz\service\activity\Page as sPage;
use Biz\service\activity\PinTuan as sPinTuan;

class IndexAction extends ActionPlugin
{

    const USER_LEVEL = self::LEVEL_NOTHING;

    public function main()
    {
        $activeTab = mMiniTab::getActiveInfo();
        $goodsRecommend = sGoodsRecommend::main();
        $hotSale = array_values(sHotSales::main());
        $pintuan = sPinTuan::getList(sPinTuan::LIST_COUNT);
        $special = sPage::getMiniActive();
        if ($activeTab) {
            $response['active'] = [
                'tabName' => $activeTab['name'],
                'tabImage' => $activeTab['pic_id'],
                'pageId' => $activeTab['page_id'],
            ];
        }
        $response['recommend'] = compact('goodsRecommend', 'pintuan', 'hotSale', 'special');
        $this->setSuccess($response);
    }
}